#ifndef MG_DRIVER_H
#define MG_DRIVER_H

#include "BSP.h"

// #define MG_CAN hcan
// #define MG_ID 0x141

typedef struct
{
    CAN_HandleTypeDef *can;
    uint16_t ID; // 电机ID
    int8_t temperature;
    float current;
    float speed;
    float encoder;
} MG_t;

void MG_CAN_Callback(CAN_RxHeaderTypeDef *pHeader, uint8_t *pBuf);
void MG_Init(MG_t *motor, uint8_t ID, CAN_HandleTypeDef *can);
void MG_Close(MG_t *motor);
void MG_Stop(MG_t *motor);
void MG_Run(MG_t *motor);
void MG_SetSpeed(MG_t *MG_Motor, float speed);
void MG_SetAngle(MG_t *MG_Motor, float angle, uint16_t maxSpeed);
void MG_SetOneAngle(MG_t *MG_Motor, float angle, uint8_t dir, uint16_t maxSpeed);
void MG_SetAngleInc(MG_t *MG_Motor, float angle, uint16_t maxSpeed);

#endif
